<!doctype html>
<html lang="en">

<head>
    <title>医院</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
        integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
    <link rel="stylesheet" href="/css/bg1.css">
</head>
<!-- <style>
    body {
        background-image: url(img/3.jpg);
    }

    .bg1 {
        opacity: 0.7;
    }
</style> -->

<body>


    <div id="app">
        <nav class="navbar navbar-expand-md  navbar-dark" style="background-color: #0991f3;">
            <a class="navbar-brand" href="#">{{title}} 🏥 </a>
            <div class="collapse navbar-collapse" id="collapsibleNavId">

                <ul class="navbar-nav mr-auto mt-2 mt-lg-0">

                    <li class="nav-item active ml-3">
                        <a class="nav-link" href="#">首页<span class="sr-only">(current)</span></a>
                    </li>
                    <li class="nav-item dropdown ml-3">
                        <a class="nav-link dropdown-toggle" href="#" id="dropdownId" data-toggle="dropdown"
                            aria-haspopup="true" aria-expanded="false">医院概况</a>

                        <div class="dropdown-menu" aria-labelledby="dropdownId">
                            <a class="dropdown-item" href="#">撤销</a>
                            <a class="dropdown-item" href="#">恢复</a>
                            <a class="dropdown-item" href="#">剪切</a>
                            <a class="dropdown-item" href="#">复制</a>
                        </div>
                    </li>

                    <li class="nav-item dropdown ml-3">
                        <a class="nav-link dropdown-toggle" href="#" id="dropdownId" data-toggle="dropdown"
                            aria-haspopup="true" aria-expanded="false">医疗服务</a>

                        <div class="dropdown-menu" aria-labelledby="dropdownId">
                            <a class="dropdown-item" href="#">撤销</a>
                            <a class="dropdown-item" href="#">恢复</a>
                            <a class="dropdown-item" href="#">剪切</a>
                            <a class="dropdown-item" href="#">复制</a>
                        </div>
                    </li>
                    <li class="nav-item dropdown ml-3">
                        <a class="nav-link dropdown-toggle" href="#" id="dropdownId" data-toggle="dropdown"
                            aria-haspopup="true" aria-expanded="false">学术交流</a>

                        <div class="dropdown-menu" aria-labelledby="dropdownId">
                            <a class="dropdown-item" href="#">撤销</a>
                            <a class="dropdown-item" href="#">恢复</a>
                            <div class="dropdown-divider"></div>
                            <a class="dropdown-item" href="#">剪切</a>
                            <a class="dropdown-item" href="#">复制</a>
                        </div>
                    </li>
                </ul>
                <form class="form-inline my-2 my-lg-0">
                    <input class="form-control mr-sm-2" type="text" placeholder="Search">
                    <button class="btn btn-danger my-2 my-sm-0" type="submit">Search</button>
                </form>
            </div>
        </nav>

        <div class="jumbotron jumbotron-fluid py-3 bg1">
            <div class="container">

                <h1 class="display-4">线上挂号系统</h1>
                <p class="lead">荔枝医院</p>
            </div>

            <nav class="breadcrumb">
                <span class="breadcrumb-item active">首页</span>
                <a class="breadcrumb-item" href="keshi.html">{{curDepart}}排班</a>
                <a class="breadcrumb-item" href="patient.html">就诊人管理</a>
                <a class="breadcrumb-item" href="appointment.html">我的预约信息</a>
            </nav>
        </div>


        <div class="container ">

            <div class="row">

                <div class="col-lg-3 col-md-2 col-sm-12 ">

                    <h1 class="lead">科室导航</h1>

                    <ul class="list-group">

                        <li class="list-group-item" v-for="(depart, index) in department" :key="index">
                            {{depart.title}}
                            <div class="list-group">
                                <a v-for="(subdepart, index) in depart.sub" :key="index"
                                    @click="getCurrDepartment(subdepart)"
                                    class="list-group-item list-group-item-action ">
                                    {{subdepart.title}}
                                </a>

                            </div>
                        </li>

                    </ul>
                </div>

                <div class="col-md-8 col-12">
                    <h1 class="lead">名医导航</h1>

                    <div class="row">

                        <div class="col-md-3 col-sm-6 col-6 mb-3" v-for="(doc, index) in doctor" :key="index">
                            <div class="card">

                                <img :src="doc.img" width="100%" height="170px" />
                                <div class="card-body text-center">
                                    <h3 class="card-title">{{doc.name}}</h3>
                                    <p class="card-text">{{doc.level}}</p>
                                    <p class="card-text">{{doc.department.title}}</p>
                                </div>
                                <a @click="getDoctor(doc)" type="button" class="btn btn-outline-danger">挂号</a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>


    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
        integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
        crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"
        integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1"
        crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"
        integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM"
        crossorigin="anonymous"></script>
</body>

</html>
<script>

    const vm = new Vue({
        el: "#app",
        data() {
            return {
                title: "荔枝医院",
                curDepart: "请选择科室",

                department: null,

                doctor: []
            }
        },
        mounted() {
            this.setSeesion(this.curDepart);
            this.getallDepartment();
        },
        methods: {

            getDoctor(doctor) {

                sessionStorage.setItem("doctor", JSON.stringify(doctor));

                window.location.href = "doctor.html";
            },
            getallDepartment() {

                axios.get('http://120.24.192.41:8080/api/department')
                    .then(function (response) {

                        vm.department = response.data;
                    })
                    .catch(function (error) {

                        console.log(error);
                    })
            },

            setSeesion(depart) {
                sessionStorage.setItem("curDepart", depart);
            },

            getCurrDepartment(curdepart) {

                this.doctor = [];
                this.curDepart = curdepart.title;

                this.setSeesion(JSON.stringify(curdepart));

                axios.get(`http://localhost:8080/api/doctor/${curdepart.id}`)
                    .then((response) => {

                        this.doctor = response.data;
                    })
                    .catch(function (error) {
                    })
            }
        },
    })

</script>